package fall2014.cs343.lab2.multithreading;

/**
 * AThread - Simple Thread class.
 * 
 * This class introduces basic concepts in setting up an application
 * with multiple threads. 
 * 
 *
 */
public class AThread extends Thread{
	
	private static int asset = 0;
	public static final int target = 200;

	private int data = 0;

	/**
	 * Default Constructor
	 */
	public AThread() {
		data = 0;
	}

	/**
	 * Constructor with String parameter
	 * @param name
	 */
	public AThread(String name) {
		super(name);
	}

	/**
	 * public void run method 
	 * 
	 * this is where the work gets done in the thread
	 */
	public void run(){
		while (asset < target){
			work();
			asset += 10;
			System.out.println(" " + getName() + ": Asset is now " + asset);
		}
		System.out.println(" " + getName() + ": Performed " + data + " iterations.");
	}

	private void work(){
		data++;
	}

}
